import {
    _decorator,
    AudioClip,
    Component,
    Node,
    Slider,
    Toggle,
} from 'cc';
import { AudioMgr } from 'db://assets/component/audio/AudioMgr';
const { ccclass, property } = _decorator;

@ccclass('AudioTest2')
export class AudioTest2 extends Component {
    @property(AudioClip)
    bgmClip: AudioClip = null!;

    @property(AudioClip)
    otherClip: AudioClip = null!;

    audioMgr: AudioMgr = null!;

    protected __preload(): void {
        this.audioMgr = new AudioMgr();
    }
    protected onLoad(): void {}

    start() {}

    update(deltaTime: number) {}

    playBgm() {
        this.audioMgr.playBg(this.bgmClip);
    }

    setVolume(slider: Slider) {
        this.audioMgr.setBgVolume(slider.progress);
    }

    onChecked(checkbox: Toggle) {
        this.audioMgr.setBgOn(checkbox.isChecked);
    }

    onChangeBgm() {
        this.audioMgr.playBg(this.otherClip);
    }
}
